package threadcoreknowledge.uncaughtexception;

/**
 * 描述：     使用刚才自己写的UncaughtExceptionHandler
 */
public class UseOwnUncaughtExceptionHandler implements Runnable {

    public static void main(String[] args) throws InterruptedException {
        Thread.setDefaultUncaughtExceptionHandler(new MyUncaughtExceptionHandler("捕获器1"));

        new Thread(new UseOwnUncaughtExceptionHandler(), "MyThread-1").start();
        Thread.sleep(300);
//        new Thread(new UseOwnUncaughtExceptionHandler(), "MyThread-2").start();
//        Thread.sleep(300);
//        new Thread(new UseOwnUncaughtExceptionHandler(), "MyThread-3").start();
//        Thread.sleep(300);
//        new Thread(new UseOwnUncaughtExceptionHandler(), "MyThread-4").start();

        System.out.println("main线程执行完毕");
    }


    @Override
    public void run() {
//        throw new RuntimeException();
        int i=1/0;
        System.out.println("i的结果是"+i);
    }
}
